|
|
|
| Table 6.4 Variable Naming Standards. | | Data Type | Sample Names | Default Values | | Boolean | boolPerform | False | | Byte | bytValue | 0 | | Date | dtEntry | December 30, 1899; 12:00:00 AM | | Integer | intLoop | 0 | | Long | lngAmount | 0 | | Single | sngAmount | 0 | | Double | dblValue | 0 | | Currency | curChkAmt | 0 | | String | strCompany | "" | | Variant | vntVar1 | Empty |
|
 |
|
|
|
|
TIP Always use Hungarian Notation when naming variables. This will make your variable names much more descriptive and will make your programs easier to read. If you are not familiar with Hungarian Notation please refer to Appendix A of this book. |
|
|
|
|
|
|
|
|
As you saw in the previous examples, the scope of the variable is used as a modifier to the name of the variable. For Public variables, you use the letter g, which stands for Global. The reason for this is because the keyword Public was not introduced until Visual Basic 4, and most people had already adopted the standard prefix g for the old declaration Global. |
|
|
|
|
|
|
|
|
The prefix m is added to the names of all module-level variables declared in the (General) (Declarations) section. No prefix is used for local variables in a procedure. |
|
|
|
|
|
|
|
|
The Variant data type allows you to store any type of data in a variable. This variable can change its type at any time. When it does, Visual Basic takes care of all the housekeeping chores. Because its such a flexible data type, it carries much more overhead (memory and resources) than a normal data type. Therefore, you should only use the Variant data type as a last resort. |
|
|
|
|
|